<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>练习</title>
</head>
<body>
<input type="text" id="i1" placeholder="输入一个数字">
<input type="button" value="添加帅哥" onclick="f(1)">
<input type="button" value="添加美女" onclick="f(2)">

<script>
    let i = document.querySelector("#i1");
    function f(x) {
        let imgName = x==1?"../b.jpg":"../day01/a.jpg";
        for (let j = 0; j < i.value; j++) {
            let img = document.createElement("img");
            img.src = imgName;
            img.width = 200;
            img.height = 200;
            document.body.append(img);
        }
    }
</script>
</body>
</html>